//
//  CallUtil.m
//  SmartRoadShow
//
//  Created by Tracy E on 10-9-28.
//  Copyright 2010 simonwang142232@gmail.com. All rights reserved.
//

#import "CallUtil.h"


@implementation CallUtil

static NSString * number;
static CallUtil* callUtil;

+(CallUtil*)getInstance{
	if(callUtil == nil){
		callUtil = [[CallUtil alloc] init];
	}
	return callUtil;
}

- (void)callPhoneNumber:(NSString *)phoneNumber{
	UIAlertView *alert = [[UIAlertView alloc] initWithTitle:[NSString stringWithFormat:@"您确认要拨打%@电话吗？",phoneNumber]
													message:nil
												   delegate:self
										  cancelButtonTitle:@"确认"
										  otherButtonTitles:@"取消",nil];
	number = phoneNumber;
	[alert show];
	[alert release];
	

}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
	if (buttonIndex == 0) {
		number = [number stringByReplacingOccurrencesOfString:@"-" withString:@""];
		number = [number stringByReplacingOccurrencesOfString:@" " withString:@""];
		number = [number stringByReplacingOccurrencesOfString:@"(86)" withString:@""];
		NSLog(@"call:%@",number);
		NSString* phoneNumberURL = [NSString stringWithFormat: @"tel://%@",number];
		[[UIApplication sharedApplication] openURL:[NSURL URLWithString:phoneNumberURL]];
	}
}

@end
